/*整理接口,2017/07/26, author:lanlan.zeng*/
//新增病历
function grey_post_medical_record(patientName,realName,tel,addr, patientSex,birthday,id_card,insuranceType,success, fail) {
    var dto = {};

 
    dto.insurance_type = insuranceType;
    var patient={};
    patient.name=patientName;
    patient.real_name=realName;
    patient.mobile=tel;
    patient.address=addr;
    patient.sex=patientSex;
    patient.birthday=birthday;
    patient.identity_card=id_card;
    dto.patient=patient;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPostSyn("/mandy/emr.json", dto, success, fail);
}

//获取当前医生详细信息
function grey_get_medical_staff_info(medicalStaffId, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.medical_staff_id = medicalStaffId;
    doGet("/mandy/medical_staff.json", dto, success, fail);
}

//获取当前医生详细信息
function grey_get_profile(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/profile.json", dto, success, fail);
}

//获取医生列表
function grey_get_medical_staff_list(types, hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, success, fail) {
    grey_get_medical_staff_list_by_page(types, hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, 1, 10000, success, fail)
}
//获取医生列表
function grey_get_medical_staff_list_by_page(types, hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, page, pageSize, success, fail) {
    var dto = {};
    if (types != null) {
        dto.types = types;
    }
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    dto.station = station;
    dto.page = page;
    dto.page_size = pageSize;
    dto.tag_id = tagId;
    dto.sort_type = sortType;
    //if(!addTokenToDTO(dto)) {return;}
    doGet("/mandy/medical_staff_list.json", dto, success, fail);
}

//获取医院列表
function grey_get_hospital_list(name, cityId, success, fail) {
    var getHospitalList = {};

    //addTokenToDTO(getHospitalList);

    getHospitalList.hospital_name = name;
    getHospitalList.city_id = cityId;

    doGet("/mandy/hospital_list.json", getHospitalList, success, fail);
}

//获取科室列表
function grey_get_division_list(success, fail) {
    var getDivisionList = {};

    addTokenToDTO(getDivisionList);

    doGet("/mandy/division_list.json", getDivisionList, success, fail);
}

//获取角色列表
function grey_get_role_list(success, fail) {
    var getRoleList = {};

    addTokenToDTO(getRoleList);

    doGet("/mandy/role_list.json", getRoleList, success, fail);
}

//获取疾病列表
function grey_get_all_disease(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/disease_list.json", dto, success, fail);
}

//获取量表列表
function grey_get_gauge_by_disease_id(disease_id,success, fail) {
    var dto = {};
    dto.disease_id=disease_id;
    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/gauge_list.json", dto, success, fail);
}

//康复列表
function grey_get_prescription_list_by_emr_id(emr_id,page,pageSize,success, fail) {
    var dto = {};

    dto.emr_id = emr_id;
    dto.page = page;
    dto.page_size = pageSize;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/prescription_list_by_emr_id.json", dto, success, fail);
}

//获取医院信息
function grey_get_hospital(id, success, fail) {
    var getHospital = {};

    getHospital.hospital_id = id;

    doGet("/mandy/hospital.json", getHospital, success, fail);
}

//获取医生信息
function grey_get_medical_staff(medical_staff_id, success, fail) {
    var dto = {};
    dto.medical_staff_id = medical_staff_id;
    doGet("/mandy/medical_staff.json", dto, success, fail);
}

//康复处方列表
function grey_get_prescription_by_emr_id(emr_id,type,is_referral_history, success, fail) {
    var dto = {};

    dto.emr_id = emr_id;
    dto.type = type;
    dto.is_referral_history = is_referral_history;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/prescription_by_emr_id.json", dto, success, fail);
}

//康复处方
function grey_get_prescription(prcpId,emr_id,is_referral_history, success, fail) {
    var dto = {};

    dto.prcp_id = prcpId;
    dto.emr_id = emr_id;
    dto.is_referral_history = is_referral_history;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/prescription.json", dto, success, fail);
}

/**********待写接口文档***************************/
//文件上传相关
function grey_get_certificate_upload_info(file, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    var filename = file.name;

    dto.type = filename.substr(filename.lastIndexOf(".") + 1);

    if (dto.token == null || dto.token == "") {
        errorAlert("需要登陆");
        return false;
    }

    doGet("/mandy/certificate_upload_info.json", dto, success, fail);
}

/**********************无用接口**************************************/
//Profile相关
/*function grey_add_profile(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPost("/mandy/profile.json", dto, success, fail);
}

function grey_get_profile_sync(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGetSyn("/mandy/profile.json", dto, success, fail);
}

function grey_set_profile(head, name, sex, birthday, success, fail) {
    var dto = {};
    dto.head = head;
    dto.name = name;
    dto.sex = sex;
    dto.birthday = birthday;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/profile.json", dto, success, fail);
}



//文件上传相关(同步接口)
function grey_get_certificate_upload_info_syn(file, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    var filename = file.name;

    dto.type = filename.substr(filename.lastIndexOf(".") + 1);

    if (dto.token == null || dto.token == "") {
        errorAlert("需要登陆");
        return false;
    }

    doGetSyn("/mandy/certificate_upload_info.json", dto, success, fail);
}

//文件上传相关（压缩后调用）
function grey_get_certificate_upload_info_compress(format, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }

    dto.type = format;

    if (dto.token == null || dto.token == "") {
        errorAlert("需要登陆");
        return false;
    }

    doGet("/mandy/certificate_upload_info.json", dto, success, fail);
}

function grey_get_avatar_upload_info(file, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    var filename = file.name;

    dto.type = filename.substr(filename.lastIndexOf(".") + 1);

    if (dto.token == null || dto.token == "") {
        errorAlert("需要登陆");
        return false;
    }

    doGet("/mandy/avatar_upload_info.json", dto, success, fail);
}

//医师相关
function grey_add_medical_application(avatar_img, birthday, name, job, role, hospital_id,
                                      new_hospital, division_id, introduction,
                                      licence_img, certification_img, position,
                                      title, email, address, sex, create_time,
                                      update_time, success, fail) {
    var dto = {};
    dto.role = {};
    dto.role.id = role;
    dto.avatar_img = avatar_img;
    dto.birthday = birthday;
    dto.name = name;
    dto.job = job;
    dto.hospital = {};
    dto.sex = sex;
    dto.hospital.id = hospital_id;
    dto.new_hospital = new_hospital;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.position = position;
    dto.title = title;
    dto.contact_email = email;
    dto.address = address;

    dto.licence_img = licence_img[0];
    dto.licence_img_2 = licence_img[1];
    dto.certification_img = certification_img[0];
    dto.certification_img_2 = certification_img[1];

    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/medical_application.json", dto, success, fail);
}

//医师相关
function grey_add_medical_application2(avatar_img, name, hospital_id, division_id, position, job, introduction, licence_img, success, fail) {
    var dto = {};
    dto.avatar_img = avatar_img;
    dto.name = name;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.job = job;
    dto.division = {};
    dto.division.id = division_id;
    dto.position = position;
    dto.introduction = introduction;
    dto.licence_img = licence_img;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/medical_application.json", dto, success, fail);
}

//医师相关
function grey_get_medical_application(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/medical_application.json", dto, success, fail);
}

function grey_medical_application_approval(apply_id, hospital_id, status, remark, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.apply_id = apply_id;
    dto.hospital_id = hospital_id;
    dto.status = status;
    dto.remark = remark;

    doPut("/mandy/medical_application_approval.json", dto, success, fail);
}


//医师相关
function grey_add_doctor_application(avatar_img, role, hospital_id, new_hospital, division_id, introduction, licence_img, certification_img, position, title, email, address, create_time, update_time, success, fail) {
    var dto = {};
    dto.role = {};
    dto.role.id = role;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.new_hospital = new_hospital;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.position = position;
    dto.title = title;
    dto.contact_email = email;
    dto.address = address;

    dto.licence_img = licence_img;
    dto.certification_img = certification_img;

    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/doctor_application.json", dto, success, fail);
}

function grey_update_doctor_application(apply_id, hospital_id, division_id, introduction, licence_img, certification_img, create_time, update_time, success, fail) {
    var dto = {};
    dto.apply_id = apply_id;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.licence_img = licence_img;
    dto.certification_img = certification_img;
    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/doctor_pro_application.json", dto, success, fail);
}

function grey_get_doctor_application(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/doctor_application.json", dto, success, fail);
}

function grey_doctor_application_approval(apply_id, status, remark, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.apply_id = apply_id;
    dto.status = status;
    dto.remark = remark;

    doPut("/mandy/doctor_application_approval.json", dto, success, fail);
}

//专家医师相关
function grey_add_doctor_pro_application(avatar_img, role, hospital_id, new_hospital, division_id, introduction, licence_img, certification_img, position, title, email, address, create_time, update_time, success, fail) {
    var dto = {};
    dto.role = {};
    dto.role.id = role;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.new_hospital = new_hospital;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.position = position;
    dto.title = title;
    dto.contact_email = email;
    dto.address = address;

    dto.licence_img = licence_img;
    dto.certification_img = certification_img;

    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPost("/mandy/doctor_pro_application.json", dto, success, fail);
}

function grey_update_doctor_pro_application(apply_id, hospital_id, division_id, position, title, introduction, licence_img, certification_img, create_time, update_time, success, fail) {
    var dto = {};
    dto.apply_id = apply_id;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.division = {};
    dto.division.id = division_id;
    dto.position = position;
    dto.title = title;
    dto.introduction = introduction;
    dto.licence_img = licence_img;
    dto.certification_img = certification_img;
    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/doctor_pro_application.json", dto, success, fail);
}

function grey_get_doctor_pro_application(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/doctor_pro_application.json", dto, success, fail);
}

function grey_doctor_pro_application_approval(apply_id, status, remark, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.apply_id = apply_id;
    dto.status = status;
    dto.remark = remark;

    doPut("/mandy/doctor_pro_application_approval.json", applicationApprovalDTO, success, fail);
}

//护士相关
function grey_add_nurse_application(avatar_img, role, hospital_id, new_hospital, division_id, introduction, licence_img, certification_img, position, title, email, address, create_time, update_time, success, fail) {
    var dto = {};
    dto.role = {};
    dto.role.id = role;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.new_hospital = new_hospital;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.position = position;
    dto.title = title;
    dto.contact_email = email;
    dto.address = address;

    dto.licence_img = licence_img;
    dto.certification_img = certification_img;

    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPost("/mandy/nurse_application.json", dto, success, fail);
}

function grey_update_nurse_application(apply_id, hospital_id, division_id, introduction, licence_img, certification_img, create_time, update_time, success, fail) {
    var dto = {};
    dto.apply_id = apply_id;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.licence_img = licence_img;
    dto.certification_img = certification_img;
    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/nurse_application.json", dto, success, fail);
}

function grey_get_nurse_application(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/nurse_application.json", dto, success, fail);
}

function grey_nurse_application_approval(apply_id, status, remark, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.apply_id = apply_id;
    dto.status = status;
    dto.remark = remark;

    doPut("/mandy/nurse_application_approval.json", dto, success, fail);
}

//治疗师相关
function grey_add_therapist_application(avatar_img, role, hospital_id, new_hospital, division_id, introduction, licence_img, certification_img, position, title, email, address, create_time, update_time, success, fail) {
    var dto = {};
    dto.role = {};
    dto.role.id = role;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.new_hospital = new_hospital;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.position = position;
    dto.title = title;
    dto.contact_email = email;
    dto.address = address;

    dto.licence_img = licence_img;
    dto.certification_img = certification_img;

    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPost("/mandy/therapist_application.json", dto, success, fail);
}

function grey_update_therapist_application(apply_id, hospital_id, division_id, introduction, certification_img, create_time, update_time, success, fail) {
    var dto = {};
    dto.apply_id = apply_id;
    dto.hospital = {};
    dto.hospital.id = hospital_id;
    dto.division = {};
    dto.division.id = division_id;
    dto.introduction = introduction;
    dto.certification_img = certification_img;
    dto.create_time = create_time;
    dto.update_time = update_time;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/therapist_application.json", dto, success, fail);
}

function grey_get_therapist_application(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/therapist_application.json", dto, success, fail);
}

function grey_therapist_application_approval(apply_id, status, remark, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.apply_id = apply_id;
    dto.status = status;
    dto.remark = remark;

    doPut("/mandy/therapist_application_approval.json", dto, success, fail);
}

//住院总相关
function grey_set_resident(mobile, success, fail) {
    var dto = {};

    dto.mobile = mobile;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/resident.json", dto, success, fail);
}

function grey_delete_resident(mobile, success, fail) {
    var dto = {};

    dto.mobile = mobile;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doDelete("/mandy/resident.json", dto, success, fail);
}

//用户档案相关
function grey_get_patient_record_list(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_record_list.json", dto, success, fail);
}

function grey_get_patient_record(id, success, fail) {
    var dto = {};
    dto.patient_id = id;
    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_record.json", dto, success, fail);
}

function grey_add_patient_record(name, mobile, sex, birthday, blood_group, height, weight, married, location, is_default, success, fail) {
    var dto = {};
    dto.name = name;
    dto.mobile = mobile;
    dto.sex = sex;
    dto.birthday = birthday;
    dto.blood_group = blood_group;
    dto.height = height;
    dto.weight = weight;
    dto.married = married;
    dto.location = location;
    dto.is_default = is_default;

    if (!addTokenToDTO(dto)) {
        return;
    }
    debugAlert(dto);
    doPost("/mandy/patient_record.json", dto, success, fail);
}

function grey_update_patient_record(id, name, mobile, sex, birthday, blood_group, height, weight, married, location, is_default, success, fail) {
    var dto = {};
    dto.id = id;
    dto.name = name;
    dto.mobile = mobile;
    dto.sex = sex;
    dto.birthday = birthday;
    dto.blood_group = blood_group;
    dto.height = height;
    dto.weight = weight;
    dto.married = married;
    dto.location = location;
    dto.is_default = is_default;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/patient_record.json", dto, success, fail);
}

function grey_delete_patient_record(id, success, fail) {
    var dto = {};
    dto.patient_id = id;
    if (!addTokenToDTO(dto)) {
        return;
    }

    doDelete("/mandy/patient_record.json", dto, success, fail);
}

function grey_get_my_patients_info(patient_id, success, fail) {
    var dto = {};
    dto.patient_id = patient_id;
    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/my_patient_info.json", dto, success, fail);
}

function grey_get_patient_patient_remark_list(patient_id, success, fail) {
    var dto = {};
    dto.patient_id = patient_id;
    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_remark_list.json", dto, success, fail);
}

function grey_get_patient_history_order(patient_id, success, fail) {
    var dto = {};
    dto.patient_id = patient_id;
    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_history_order.json", dto, success, fail);
}


function grey_get_medical_staff_list_by_page_sync(types, hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, page, pageSize, success, fail) {
    var dto = {};
    if (types != null) {
        dto.types = types;
    }
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    dto.station = station;
    dto.page = page;
    dto.page_size = pageSize;
    dto.tag_id = tagId;
    dto.sort_type = sortType;
    //if(!addTokenToDTO(dto)) {return;}
    doGetSyn("/mandy/medical_staff_list.json", dto, success, fail);
}

function grey_get_srv_plug_medical_staff_list(hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    dto.station = station;
    dto.tag_id = tagId;
    dto.sort_type = sortType;
    dto.page = 1;
    dto.page_size = 10000;
    doGet("/mandy/srv_plus_staff.json", dto, success, fail);
}

function grey_get_srv_plug_medical_staff_list_by_page(hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, page, pageSize, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    dto.station = station;
    dto.tag_id = tagId;
    dto.sort_type = sortType;
    dto.page = page;
    dto.page_size = pageSize;
    doGet("/mandy/srv_plus_staff.json", dto, success, fail);
}

function grey_get_home_srv_medical_staff_list(hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, success, fail) {
    grey_get_home_srv_medical_staff_list_by_page(hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, 1, 10000, success, fail)
}

function grey_get_home_srv_medical_staff_list_by_page(hospitalId, divisionId, station, provinceId, cityId, districtId, tagId, sortType, page, pageSize, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    dto.station = station;
    dto.tag_id = tagId;
    dto.sort_type = sortType;
    dto.page = page;
    dto.page_size = pageSize;
    doGet("/mandy/home_srv_staff.json", dto, success, fail);
}

function grey_get_doctor_list(hospitalId, divisionId, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/doctor_list.json", dto, success, fail);
}

function grey_get_doctor_pro_list(hospitalId, divisionId, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/doctor_pro_list.json", dto, success, fail);
}

function grey_get_nurse_list(hospitalId, divisionId, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/nurse_list.json", dto, success, fail);
}

function grey_get_therapist_list(hospitalId, divisionId, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/therapist_list.json", dto, success, fail);
}

//function grey_get_bed(hospitalId, divisionId, provinceId, cityId, districtId, success, fail) {
//    var dto = {};
//    dto.hospital_id = hospitalId;
//    dto.division_id = divisionId;
//    dto.province_id = provinceId;
//    dto.city_id = cityId;
//    dto.district_id = districtId;
//    dto.page = 1;
//    dto.page_size = 100000;
//    //if (!addTokenToDTO(dto)) {
//    //    return;
//    //}
//    doGet("/mandy/bed.json", dto, success, fail);
//}

function grey_get_bed_appoint_time(startTime, endTime, hospitalId, divisionId, success, fail) {
    var dto = {};
    dto.start_time = startTime;
    dto.end_time = endTime;
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    doGet("/mandy/bed_appoint_time.json", dto, success, fail);
}

function grey_get_bed_hospital_list(hospitalId, divisionId, provinceId, cityId, districtId, page, pageSize, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    //dto.page = page;
    //dto.page_size = pageSize;
    //if (!addTokenToDTO(dto)) {
    //    return;
    //}
    doGet("/mandy/bed_hospital.json", dto, success, fail);
}

//function grey_get_bed_time(dayBegin, dayEnd, hospitalId, divisionId, success, fail) {
//    var dto = {};
//    dto.start_time = dayBegin;
//    dto.end_time = dayEnd;
//    dto.hospital_id = hospitalId;
//    dto.division_id = divisionId;
//    //if (!addTokenToDTO(dto)) {
//    //    return;
//    //}
//    doGet("/mandy/bed_appoint_time.json", dto, success, fail);
//}

function grey_get_bed_hospital(hospitalId, divisionId, provinceId, cityId, districtId, page, pageSize, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    //dto.page = page;
    //dto.page_size = pageSize;
    //if (!addTokenToDTO(dto)) {
    //    return;
    //}
    doGet("/mandy/bed_hospital.json", dto, success, fail);
}

function grey_update_bed(id, hospitalId, divisionId, emptyBed, totalBed, success, fail) {
    var dto = {};
    dto.id = id;
    dto.hospital = {};
    dto.hospital_id = hospitalId;
    dto.division = {};
    dto.division_id = divisionId;
    dto.empty_bed = emptyBed;
    dto.total_bed = totalBed;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/bed.json", dto, success, fail);
}

function grey_add_hospital_appointment(appointId, patientId, description, success, fail) {
    var dto = {};
    //dto.hospital = {};
    //dto.hospital.id = hospitalId;
    //dto.division = {};
    //dto.division.id = divisionId;
    dto.setting_id = appointId;
    dto.patient = {};
    dto.patient.id = patientId;
    //dto.start_time = start_time;
    dto.description = description;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/hospital_appointment.json", dto, success, fail);
}

function grey_get_hospital_appointment(role, isFinished, start_time, end_time, success, fail) {
    var dto = {};
    dto.role = role;
    dto.is_finished = isFinished;
    dto.start_time = start_time;
    dto.end_time = end_time;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/hospital_appointment.json", dto, success, fail);
}

function grey_get_hospital_appointment_page_list(role, isFinished, start_time, end_time, page, pageSize, success, fail) {
    var dto = {};
    dto.role = role;
    dto.is_finished = isFinished;
    dto.start_time = start_time;
    dto.end_time = end_time;
    dto.page = page;
    dto.page_size = pageSize;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/hospital_appointment.json", dto, success, fail);
}


//住院总审批住院申请
function grey_put_hospital_appointment(appointId, status, opinion, update_date, success, fail) {
    var dto = {};
    dto.appoint_id = appointId;
    dto.status = status;
    dto.opinion = opinion;
    dto.update_date = update_date;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/hospital_appointment.json", dto, success, fail);
}


//function grey_update_hospital_appointment(id, status, success, fail) {
//    var dto = {};
//    dto.id = id;
//    dto.status = status;
//    if (!addTokenToDTO(dto)) {
//        return;
//    }
//    doPut("/mandy/hospital_appointment.json", dto, success, fail);
//}

function grey_delete_hospital_appointment(id, success, fail) {
    var dto = {};
    dto.appoint_id = id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doDelete("/mandy/hospital_appointment.json", dto, success, fail);
}

function grey_put_hospital_appointment_confirm(id, success, fail) {
    var dto = {};
    dto.appoint_id = id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/hospital_appointment_confirm.json", dto, success, fail);
}

function grey_get_srv_goods(worker_id, srv_type, success, fail) {
    var dto = {};
    dto.worker_id = worker_id;
    dto.srv_type = srv_type;
    //if(!addTokenToDTO(dto)) {return;}
    doGet("/mandy/srv_goods.json", dto, success, fail);
}

function grey_add_srv_goods(patientId, goods_id, count, couponId, description, success, fail) {
    var dto = {};
    dto.patient_id = patientId;
    dto.goods_id = goods_id;
    dto.count = count;
    dto.coupon_id = couponId;
    dto.description = description;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/srv_goods_order.json", dto, success, fail);
}

function grey_add_srv_goods_chat(patientId, workerId, count, couponId, description, success, fail) {
    var dto = {};
    dto.patient_id = patientId;
    dto.worker_id = workerId;
    dto.srv_name = "图文咨询";
    dto.count = count;
    dto.coupon_id = couponId;
    dto.description = description;
    //dto.payment = payment;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/srv_goods_order.json", dto, success, fail);
}

function grey_get_srv_goods_order(orderId, success, fail) {
    var dto = {};
    dto.order_no = orderId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/srv_goods_order.json", dto, success, fail);
}

function grey_get_order_info(orderId, success, fail) {
    var dto = {};
    dto.order_no = orderId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/order_info.json", dto, success, fail);
}

function grey_delete_srv_goods_order(orderId, success, fail) {
    var dto = {};
    dto.order_no = orderId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doDelete("/mandy/srv_goods_order.json", dto, success, fail);
}

function grey_get_purchased_srv_goods(role, srv_type, is_finished, start_time, end_time, success, fail) {
    grey_get_purchased_srv_goods_by_page(role, srv_type, is_finished, start_time, end_time, 1, 10000, success, fail);
}

function grey_get_purchased_srv_goods_by_page(role, srv_type, is_finished, start_time, end_time, page, pageSize, success, fail) {
    //role 1 为医生
    //srv_type
    var dto = {};
    dto.role = role;

    dto.srv_type = srv_type;
    dto.page = page;
    dto.page_size = pageSize;
    dto.is_finished = is_finished;
    dto.start_time = start_time;
    dto.end_time = end_time;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/purchased_srv_goods.json", dto, success, fail);
}

function grey_add_free_question(patientId, images, description, success, fail) {
    var dto = {};
    dto.patient_id = patientId;
    if (images == null) {
        dto.images = [];
    } else {
        dto.images = images;
    }
    dto.description = description;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/question.json", dto, success, fail);
}

function grey_set_free_question(order_id, success, fail) {
    var dto = {};
    dto.order_id = order_id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/question.json", dto, success, fail);
}

function grey_get_not_replied_question(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/not_replied_question.json", dto, success, fail);
}

function grey_get_focus(role, success, fail) {
    var dto = {};
    dto.role = role;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/focus.json", dto, success, fail);
}
function grey_get_focus_syn(role, success, fail) {
    var dto = {};
    dto.role = role;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/focus.json", dto, success, fail);
}


function grey_get_special_focus(role, success, fail) {
    var dto = {};
    dto.role = role;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/special_focus.json", dto, success, fail);
}

function grey_get_special_focus_syn(role, success, fail) {
    var dto = {};
    dto.role = role;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/special_focus.json", dto, success, fail);
}

function grey_add_focus(role, accId, success, fail) {
    var dto = {};
    dto.role = role;
    dto.focus_acc_id = accId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/focus.json", dto, success, fail);
}

function grey_delete_focus(role, accId, success, fail) {
    var dto = {};
    dto.role = role;
    dto.focus_acc_id = accId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doDelete("/mandy/focus.json", dto, success, fail);
}

function grey_get_is_focused(role, doctorId, success, fail) {
    var dto = {};
    dto.role = role;
    dto.focus_acc_id = doctorId;
    if (hasToken()) {
        if (!addTokenToDTO(dto)) {
            return;
        }
        doGet("/mandy/is_focused.json", dto, success, fail);
    }
}

function grey_get_tks_letter(workerId, success, fail) {
    var dto = {};
    if (workerId == null) {
        if (!addTokenToDTO(dto)) {
            return;
        }
    } else {
        dto.worker_id = workerId;
    }
    doGet("/mandy/tks_letter.json", dto, success, fail);
}

function grey_add_tks_letter(type, text, amount, medical_staff_id, patientId, success, fail) {
    var dto = {};
    dto.type = type;
    dto.text = text;
    dto.amount = amount;
    dto.medical_staff_id = medical_staff_id;
    dto.patient_id = patientId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/tks_letter.json", dto, success, fail);
}

function grey_get_medical_service(id, srvType, success, fail) {
    var dto = {};
    if (id != null) {
        dto.worker_id = id;
    }
    if (srvType != null) {
        dto.srv_type = srvType;
    }
    if (hasToken()) {
        addTokenToDTO(dto);
    }
    doGet("/mandy/medical_service.json", dto, success, fail);
}

function grey_set_service_enable(id, enable, success, fail) {
    var dto = {};
    dto.id = id;
    dto.enable = enable;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/service_enable.json", dto, success, fail);
}

//service_status

function grey_post_medical_service(serviceDto, dtos, success, fail) {
    var dto = {};
    dto.srv_type = serviceDto.srv_type;
    dto.price = serviceDto.price;
    dto.setting_list = dtos;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/medical_service.json", dto, success, fail);
}

//function grey_add_tks_letter(success,fail){
//    var dto = {};
//    if(!addTokenToDTO(dto)) {return;}
//    doGet("/mandy/tks_letter.json", dto, success, fail);
//}

function grey_set_tks_letter(letter_id, status, success, fail) {
    var dto = {};
    dto.letter_id = letter_id;
    dto.status = status;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/tks_letter.json", dto, success, fail);
}

function grey_get_my_patients(success, fail) {
    var dto = {};
    dto.page = 1;
    dto.page_size = 10000;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/my_patients.json", dto, success, fail);
}

function grey_get_service_setting(workerId, srvType, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.worker_id = workerId;
    dto.srv_type = srvType;
    doGet("/mandy/service_setting.json", dto, success, fail);
}

function grey_delete_service_setting(workerId, ids, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.worker_id = workerId;
    dto.ids = ids;
    doDelete("/mandy/service_setting.json", dto, success, fail);
}

function grey_get_my_service_new_status(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/my_service_new_status.json", dto, success, fail);
}

//获取当前医生提交申请的信息
function grey_get_personal_info(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/personal_info.json", dto, success, fail);
}

//获取科室人员
function grey_get_division_staff_list(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/division_staff_list.json", dto, success, fail);
}

//获取住院总
function grey_get_resident_staff_list(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/resident_staff_list.json", dto, success, fail);
}

//指定住院总
function grey_resident_doctor(accId, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.acc_id = accId;
    doPut("/mandy/resident.json", dto, success, fail);
}

//取消指定住院总
function grey_cancle_resident_doctor(mobile, email, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.mobile = mobile;
    dto.email = email;
    doDelete("/mandy/resident.json", dto, success, fail);
}

//增加床位
function grey_add_bed(hospital, division, startDate, emptyBed, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.hospital = hospital;
    dto.division = division;
    dto.start_date = startDate;
    dto.empty_bed = emptyBed;
    doPost("/mandy/bed.json", dto, success, fail);
}

//批量增加或修改床位
function grey_post_bed(hospital, division, timeList, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.hospital = hospital;
    dto.division = division;
    dto.time_list = timeList;
    doPost("/mandy/bed.json", dto, success, fail);
}

//更新预约床位
function grey_update_bed_num(recordId, num, type, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.record_id = recordId;
    dto.num = num;
    dto.type = type;
    doPut("/mandy/bed.json", dto, success, fail);
}

//删除预约床位
function grey_delete_appoint_bed(recordIds, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.record_ids = recordIds;
    doDelete("/mandy/bed.json", dto, success, fail);
}

//获取市的行政区域
function grey_get_district_list(cityId, success, fail) {
    var dto = {};
    dto.city_id = cityId;
    doGet("/mandy/district_list.json", dto, success, fail);
}

function grey_get_district_list_syn(cityId, success, fail) {
    var dto = {};
    dto.city_id = cityId;
    doGetSyn("/mandy/district_list.json", dto, success, fail);
}

function grey_add_service_remark(role, orderId, remarkLevel, attitudeRemarkLevel, skillRemarkLevel, timelyRemarkLevel, remark, success, fail) {
    var dto = {};
    dto.role = role;
    dto.order_id = orderId;

    if (attitudeRemarkLevel != null) {
        dto.attitude_remark_level = attitudeRemarkLevel;
    }
    if (skillRemarkLevel != null) {
        dto.skill_remark_level = skillRemarkLevel;
    }
    if (timelyRemarkLevel != null) {
        dto.timely_remark_level = timelyRemarkLevel;
    }
    if (remarkLevel != null) {
        dto.remark_level = remarkLevel;
    }
    dto.remark = remark;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/service_remark.json", dto, success, fail);
}

function grey_get_staff_remark_list(workerId, success, fail) {
    var dto = {};
    if (workerId == null) {
        if (!addTokenToDTO(dto)) {
            return;
        }
    } else {
        dto.worker_id = workerId;
    }

    doGet("/mandy/staff_remark_list.json", dto, success, fail);
}

function grey_get_patient_remark_list(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/staff_remark_list.json", dto, success, fail);
}

function grey_get_free_dose(orderId, success, fail) {
    var dto = {};
    dto.order_id = orderId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/free_dose.json", dto, success, fail);
}

function getChargeUrl() {
    return buildUrl("/mandy/charge.json");
}

function getPayWayChargeUrl() {
    return buildUrl("/mandy/pay_way_charge.json");
}

function grey_pay(orderNo, amount) {
    var bill = {};
    bill.order_no = orderNo;
    bill.amount = amount;
    var p = {};
    p.para = bill;
    p.url = getChargeUrl();

    if (activityManager != null) {
        activityManager.startPay(JSON.stringify(p));
    } else if (iOSActionManager != null) {
        iOSActionManager.startPay(p);
    }
    debugAlert("pay done 2");
}

function grey_get_pay_way_order(success,fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/pay_way_order.json", dto, success, fail);
}

function grey_set_pay_way(success,fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/pay_way_bind.json", dto, success, fail);
}

function grey_get_pay_way(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/pay_way.json", dto, success, fail);
}

function grey_get_all_tag_syn(success, fail) {
    var dto = {};
    doGetSyn("/mandy/all_tag.json", dto, success, fail);
}

function grey_get_article_list(tag, type, page, pageSize, success, fail) {
    var dto = {};
    dto.tag = tag;
    dto.type = type;
    dto.page = page;
    dto.page_size = pageSize;
    doGet("/mandy/article_list.json", dto, success, fail);
}

function grey_get_article(id, success, fail) {
    var dto = {};
    dto.id = id;
    doGet("/mandy/article.json", dto, success, fail);
}

function grey_get_my_article(tag, page, pageSize, success, fail) {
    var dto = {};
    dto.tag = tag;
    dto.page = page;
    dto.page_size = pageSize;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/my_article.json", dto, success, fail);
}

function grey_phone_chat(orderId, success, fail) {
    var dto = {};
    dto.order_id = orderId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/phone_chat.json", dto, success, fail);
}

function grey_medical_application_total_data(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/medical_application_total_data.json", dto, success, fail);
}

function grey_medical_application_list(page, pageSize, uname, job, mobile, hospitalId, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    dto.uname = uname;
    dto.job = job;
    dto.mobile = mobile;
    dto.hospital_id = hospitalId;
    if (!addTokenToDTO(dto)) {
        return;
    }

    //alert(JSON.stringify(dto));
    doGet("/mandy/medical_application_list.json", dto, success, fail);
}

function grey_medical_application_by_id(applyId, success, fail) {
    var dto = {};
    dto.apply_id = applyId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/medical_application_by_id.json", dto, success, fail);
}

function grey_auth_medical_application(hospitalName, requestId, status, divisionId, smsMsg, roleId, success, fail) {
    var dto = {};
    dto.hospital_name = hospitalName;
    dto.apply_id = requestId;
    dto.status = status;
    dto.sms_msg = smsMsg;
    dto.division_id = divisionId;
    dto.role_id = roleId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/auth_medical_application.json", dto, success, fail);
}

function grey_get_month_settlement(month, pageSize, page, success, fail) {
    var dto = {};
    dto.month = month;
    dto.page_size = pageSize;
    dto.page = page;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/monthly_settlement.json", dto, success, fail);
}

function grey_auth_month_settlement(ids, status, chargebacks, chargebacksReason, success, fail) {
    var dto = {};
    dto.ms_ids = ids;
    dto.status = status;
    dto.chargebacks = chargebacks;
    dto.chargebacks_reason = chargebacksReason;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/auth_monthly_settlement.json", dto, success, fail);
}

function grey_get_month_settlement_detail_by_id(accountId, month, success, fail) {
    var dto = {};
    dto.account_id = accountId;
    dto.month = month;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/month_settlement_detail_by_id.json", dto, success, fail);
}

function grey_month_settlement_total_data(month, success, fail) {
    var dto = {};
    dto.month = month;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/month_settlement_total_data.json", dto, success, fail);
}

function grey_month_settlement_refund(orderId, refundReson, success, fail) {
    var dto = {};
    dto.order_id = orderId;
    dto.refund_reson = refundReson;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doDelete("/mandy/month_settlement_refund.json", dto, success, fail);
}


function grey_set_percentage(percentage, success, fail) {
    var dto = {};
    dto.percentage = percentage;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/monthly_settlement_config.json", dto, success, fail);
}

function grey_get_percentage(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/monthly_settlement_config.json", dto, success, fail);
}

function grey_get_recommend(position, pageSize, page, success, fail) {
    var dto = {};
    dto.position = position;
    dto.page_size = pageSize;
    dto.page = page;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/recommend.json", dto, success, fail);
}

function grey_get_recommend_by_id(id, success, fail) {
    var dto = {};
    dto.id = id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/recommend_detail.json", dto, success, fail);
}

function grey_add_recommend(recommend, success, fail) {
    var dto = {};
    dto.recommend = recommend;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/recommend.json", dto, success, fail);
}

function grey_update_recommend(recommend, success, fail) {
    var dto = {};
    dto.recommend = recommend;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/recommend.json", dto, success, fail);
}
function grey_get_my_wallet(startTime, endTime, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.start_time = startTime;
    dto.end_time = endTime;

    doGet("/mandy/my_wallet.json", dto, success, fail);
}

//管理端分页查询
function grey_get_medical_staff_page_list(hospitalId, divisionId, station, provinceId, cityId, districtId, page, pageSize, success, fail) {
    var dto = {};
    dto.hospital_id = hospitalId;
    dto.division_id = divisionId;
    dto.province_id = provinceId;
    dto.city_id = cityId;
    dto.district_id = districtId;
    dto.station = station;
    dto.page = page;
    dto.page_size = pageSize;
    //if(!addTokenToDTO(dto)) {return;}
    doGet("/mandy/medical_staff_page_list.json", dto, success, fail);
}

function grey_get_article_page_list(tag, type, page, pageSize, success, fail) {
    var dto = {};
    dto.tag = tag;
    dto.type = type;
    dto.page = page;
    dto.page_size = pageSize;
    doGet("/mandy/article_page_list.json", dto, success, fail);
}

//短信验证码
function grey_getMobileCode(mobile, local, type, success, fail) {

    var reg = /^[1][3-8]\d{9}$/;

    var registerDTO = {};

    debugAlert(mobile);
    if (mobile == null || mobile == "") {
        alert("手机号码不能为空");
        return false;
    }

    if (!mobile.match(reg)) {
        alert("手机号输入错误");
        return false;
    }

    registerDTO.mobile = mobile;
    registerDTO.type = type;
    if (local != null) {
        registerDTO.local = local;
    }

    doGet("/mandy/mobile_code.json", registerDTO, success, fail);
}

function grey_get_all_personal_tag(job, success, fail) {
    var dto = {};
    dto.job = job;
    //if (!addTokenToDTO(dto)) {
    //    return;
    //}
    doGet("/mandy/all_personal_tag.json", dto, success, fail);
}

function grey_get_my_personal_tag(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/my_personal_tag.json", dto, success, fail);
}

function grey_set_my_personal_tag(tagIds, success, fail) {
    var dto = {};
    dto.tag_ids = tagIds;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/my_personal_tag.json", dto, success, fail);
}

function grey_getRegisterMobileCode(mobile, local, success, fail) {
    grey_getMobileCode(mobile, local, "registration", success, fail);
}

function grey_getRsetPwdMobileCode(mobile, local, success, fail) {
    grey_getMobileCode(mobile, local, "forgetpwd", success, fail);
}

function grey_getModifyFirstMobileCode(mobile, local, success, fail) {
    grey_getMobileCode(mobile, local, "modifyfirst", success, fail);
}

function grey_getModifySecondMobileCode(mobile, local, success, fail) {
    grey_getMobileCode(mobile, local, "modifysecond", success, fail);
}

function grey_feedBack(softwareId, content, versionCode, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.content = content;
    dto.software_id = softwareId;
    dto.version_code = versionCode;
    doPost("/annie/opinion.json", dto, success, fail);
}

function send_msg_all(pushClients, msg, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.push_client = pushClients;
    dto.msg = msg;
    doPost("/mandy/push_to_all.json", dto, success, fail);
}

function grey_set_introduction(introduction, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.introduction = introduction;
    doPut("/mandy/introduction.json", dto, success, fail);
}

function grey_get_city(name, success, fail) {
    var dto = {};
    //if (!addTokenToDTO(dto)) {
    //    return;
    //}
    dto.name = name;
    doGet("/mandy/city.json", dto, success, fail);
}

function grey_get_city_sync(name, success, fail) {
    var dto = {};
    //if (!addTokenToDTO(dto)) {
    //    return;
    //}
    dto.name = name;
    doGetSyn("/mandy/city.json", dto, success, fail);
}

function grey_feedback_list(page, pageSize,uname,mobile, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    dto.uname = uname;
    dto.mobile = mobile;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/feedback.json", dto, success, fail);
}

function grey_hospital_page_list(hospital, page, pageSize, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    if (hospital != null) {
        dto.hospital_name = hospital.name;
        dto.level = hospital.level;
        dto.type = hospital.type;
    }
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/hospital_by_page.json", dto, success, fail);
}

function grey_hospital_page_list_syn(hospital, page, pageSize, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    if (hospital != null) {
        dto.hospital_name = hospital.name;
        dto.level = hospital.level;
        dto.type = hospital.type;
    }
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/hospital_by_page.json", dto, success, fail);
}

function grey_get_province_list(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/province_list.json", dto, success, fail);
}

//同步查询
function grey_get_province_list_syn(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/province_list.json", dto, success, fail);
}

function grey_get_city_list(provinceId, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.province_id = provinceId;
    doGet("/mandy/city_list.json", dto, success, fail);
}

function grey_get_city_list_syn(provinceId, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.province_id = provinceId;
    doGetSyn("/mandy/city_list.json", dto, success, fail);
}

function grey_get_distinct_list(cityId, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.city_id = cityId;
    doGet("/mandy/district_list.json", dto, success, fail);
}

function grey_add_hospital(hospitalDto, success, fail) {
    var dto = {};
    dto.hospital = hospitalDto;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/hospital.json", dto, success, fail);
}

function grey_get_hospital_detail(hospitalId, success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.hospital_id = hospitalId;
    doGet("/mandy/hospital.json", dto, success, fail);
}

function grey_update_hospital(hospitalDto, success, fail) {
    var dto = {};
    dto.hospital = hospitalDto;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/hospital.json", dto, success, fail);
}

function grey_get_all_order_list(page, pageSize, staffName, patientName, srvName, status, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    dto.staff_name = staffName;
    dto.patient_name = patientName;
    dto.srv_name = srvName;
    dto.status = status;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/all_order.json", dto, success, fail);
}

function grey_all_hospital_appointment_list(page, pageSize, patientName, status, hospitalId, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    dto.patient_name = patientName;
    dto.hospital_id = hospitalId;
    dto.status = status;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/all_hospital_appointment.json", dto, success, fail);
}

function grey_profile_list_by_page(page, pageSize, name, mobile, job, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    dto.name = name;
    dto.mobile = mobile;
    dto.job = job;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/profile_list_by_page.json", dto, success, fail);
}

function grey_patient_list_by_page(page, pageSize, name, mobile, success, fail) {
    var dto = {};
    dto.page = page;
    dto.page_size = pageSize;
    dto.name = name;
    dto.mobile = mobile;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/patient_list_by_page.json", dto, success, fail);
}

function grey_add_article(article, success, fail) {
    var dto = {};
    dto.title = article.title;
    dto.type = article.type;

    dto.cover_img = article.cover_img;
    dto.content = article.content;
    var tags = [];
    for (var i = 0; i < article.tags.length; i++) {
        var tag = {};
        tag.id = article.tags[i];
        tags[i] = tag;
    }
    dto.tags = tags;

    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/article.json", dto, success, fail);
}

function grey_update_article(article, success, fail) {
    var dto = {};
    dto.id = article.id;
    dto.title = article.title;
    dto.type = article.type;

    dto.cover_img = article.cover_img;
    dto.content = article.content;
    var tags = [];
    for (var i = 0; i < article.tags.length; i++) {
        var tag = {};
        tag.id = article.tags[i];
        tags[i] = tag;
    }
    dto.tags = tags;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/article.json", dto, success, fail);
}

function grey_get_charge_refer(orderId, success, fail) {
    var dto = {};
    dto.order_no = orderId;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/charge_refer.json", dto, success, fail);
}

function grey_get_activity_apply(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }


    doGet("/mandy/activity_apply.json", dto, success, fail);
}


function grey_add_activity_apply(activityApply, success, fail) {
    var dto = {};
    dto = activityApply;
    if (hasToken()) {
        if (!addTokenToDTO(dto)) {
            return;
        }
    }

    doPost("/mandy/activity_apply.json", dto, success, fail);
}

function grey_get_hospital_appointment_detail(appointId, success, fail) {
    var dto = {};
    dto.appoint_id = appointId;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/hospital_appointment_detail.json", dto, success, fail);
}

function grey_get_coupon(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/coupon.json", dto, success, fail);
}

function grey_get_my_coupon(isUsed, expireTime, success, fail) {
    var dto = {};

    dto.expire_time = expireTime;
    dto.is_used = isUsed;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/my_coupon.json", dto, success, fail);
}

function grey_get_coupon_type(success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/coupon_type.json", dto, success, fail);
}

function grey_get_coupon_temp_page_list(name, type, page, pageSize, success, fail) {
    var dto = {};
    dto.name = name;
    dto.type = type;
    dto.page = page;
    dto.page_size = pageSize;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/coupon_temp_by_page.json", dto, success, fail);
}

function grey_get_coupon_temp_by_id(id, success, fail) {
    var dto = {};
    dto.id = id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/coupon_temp.json", dto, success, fail);
}

function grey_update_coupon_temp(coupon_temp, success, fail) {

    if (!addTokenToDTO(coupon_temp)) {
        return;
    }
    doPut("/mandy/coupon_temp.json", coupon_temp, success, fail);
}

function grey_add_coupon_temp(coupon_temp, success, fail) {

    if (!addTokenToDTO(coupon_temp)) {
        return;
    }
    doPost("/mandy/coupon_temp.json", coupon_temp, success, fail);
}


function grey_add_coupon_grant(coupon_grant, success, fail) {

    //1.创建优惠券
    var coupon={};
    var coupon_id;

    coupon.name=coupon_grant.name;
    coupon.discount=coupon_grant.discount;
    coupon.term_of_validity=coupon_grant.term_of_validity;
    coupon.reduce_condition=coupon_grant.reduce_condition;
    coupon.platform_percent=coupon_grant.platform_percent;
    coupon.medical_percent=coupon_grant.medical_percent;
    coupon.is_medical_usable=coupon_grant.is_medical_usable
    coupon.description=coupon_grant.description;
    coupon.type=coupon_grant.type;
    coupon.start_time=coupon_grant.start_time;
    coupon.end_time=coupon_grant.end_time;

    if (!addTokenToDTO(coupon_grant)) {
        return;
    }

    console.log("grey_add_coupon_grant.coupon:"+coupon);

    doPostSyn("/mandy/coupon.json", coupon_grant, function (msg) {
        if(msg.result_code != 0){
            toastr.error(JSON.stringify(msg));
            toastr.error("优惠券添加失败");
        }else{
            processErrorCode(msg);
            if (msg.result_code != 0) {
                toastr.error(msg.result_msg);
            } else {
                console.log("coupon_id:"+msg.id);
                coupon_id=msg.id;
            }
        }
    }, fail);


    //2.发送
    var new_coupon_grant={};

    new_coupon_grant.coupon_id=coupon_id;

    //补充发送人群的筛选条件
    if(coupon_grant.grant_condition!=null){
        new_coupon_grant.grant_condition=coupon_grant.grant_condition;
    }

    new_coupon_grant.name=coupon_grant.grant_name;
    new_coupon_grant.description=coupon_grant.grant_description;
    new_coupon_grant.patient_ids=coupon_grant.patient_ids;

    if (!addTokenToDTO(new_coupon_grant)) {
        return;
    }

    doPost("/mandy/coupon_grant.json", new_coupon_grant, success, fail);

}

function grey_get_coupon_type_syn(success, fail){
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/coupon_type.json", dto, success, fail);
}

function grey_get_coupon_grant_by_page(name,page,page_size,success, fail){
    var dto={};
    dto.name=name;
    dto.page=page;
    dto.page_size=page_size;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/coupon_grant_by_page.json", dto, success, fail);
}

function grey_get_coupon_grant_by_id(id,success, fail){
    var dto={};
    dto.id=id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/coupon_grant_by_id.json", dto, success, fail);
}

function grey_get_citys_syn(ids,success, fail){
    var dto={};
    dto.city_ids=ids;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/citys.json", dto, success, fail);
}

function grey_get_recommend_by_position(position, page_size, page, success, fail){
    var dto={};
    //if (!addTokenToDTO(dto)) {
    //    return;
    //}
    dto.position = position;
    dto.page_size = page_size;
    dto.page = page;
    doGet("/mandy/recommend_by_position.json", dto, success, fail);
}

//收藏文章
function grey_post_collection(article_id,success,fail){
    var dto={};
    if(!addTokenToDTO(dto)){
        return;
    }
    dto.article_id=article_id;
    doPost("/mandy/collection.json",dto,success,fail);
}

//获取收藏的文章列表
function grey_get_my_collection(success,fail){
    var dto={};
    if(!addTokenToDTO(dto)){
        return;
    }
    doGet("/mandy/my_collection.json",dto,success,fail);
}

//取消收藏
function grey_delete_collection(article_id,success,fail){
    var dto={};
    if(!addTokenToDTO(dto)){
        return;
    }
    dto.article_id=article_id;
    doDelete("/mandy/collection.json",dto,success,fail);
}

//检查文章是否被收藏
function grey_get_is_collected(article_id,success,fail){
    var dto={};
    if(!addTokenToDTO(dto)){
        return;
    }
    dto.article_id=article_id;
    doGet("/mandy/is_collected.json",dto,success,fail);
}

//医疗文章点赞
function grey_post_like(token,article_id,success,fail){
    var dto={};
    //if(!addTokenToDTO(dto)){
    //    return;
    //}
    if(token != null && token != "") {
        dto.token = token;
    }
    dto.article_id=article_id;
    doPost("/mandy/like.json",dto,success,fail);
}

//医疗文章取消点赞
function grey_delete_like(token,article_id,success,fail){
    var dto={};
    //if(!addTokenToDTO(dto)){
    //    return;
    //}
    if(token != null && token != "") {
        dto.token = token;
    }
    dto.article_id=article_id;
    doDelete("/mandy/like.json",dto,success,fail);
}

//分享计数
function grey_post_share(article_id,success,fail){
    var dto={};
    dto.article_id=article_id;
    doPost("/mandy/share.json",dto,success,fail);
}

//分享计数
function grey_delete_share(article_id,success,fail){
    var dto={};
    dto.article_id=article_id;
    doDelete("/mandy/share.json",dto,success,fail);
}

function grey_get_patient_group(success, fail){
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/patient_group.json", dto, success, fail);
}

function grey_get_patient_list_by_group_id(groupId,success, fail){
    var dto={};
    dto.group_id=groupId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/patient_list_by_group.json", dto, success, fail);
}

function grey_get_patient_list_by_group_id_syn(groupId,success, fail){
    var dto={};
    dto.group_id=groupId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/patient_list_by_group.json", dto, success, fail);
}


function grey_add_patient_group(patient_group, success, fail) {

    if (!addTokenToDTO(patient_group)) {
        return;
    }
    doPost("/mandy/patient_group.json", patient_group, success, fail);
}

function grey_delete_patient_group(patient_group_id, success, fail) {
    var dto = {};
    var group_ids=[];
    group_ids[0]=patient_group_id
    dto.group_ids = group_ids;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doDelete("/mandy/patient_group_ids.json", dto, success, fail);
}

function grey_move_patient_to_group(patient_id,old_group_id,group_id, success, fail) {
    var dto = {};
    var patient_ids=[];
    patient_ids[0]=patient_id
    dto.group_id = group_id;
    dto.old_group_id = old_group_id;
    dto.patient_ids=patient_ids;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/move_to_group.json", dto, success, fail);
}

function grey_move_patient_out_group(patient_id,group_id, success, fail) {
    var dto = {};
    var patient_ids=[];
    patient_ids[0]=patient_id
    dto.group_id = group_id;
    dto.patient_ids=patient_ids;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/move_out_group.json", dto, success, fail);
}

function grey_update_patient_group(patient_group, success, fail) {

    if (!addTokenToDTO(patient_group)) {
        return;
    }

    doPut("/mandy/patient_group.json", patient_group, success, fail);
}

function grey_get_medical_title_list(success, fail){
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/medical_title_list.json", dto, success, fail);
}

function grey_get_my_no_prescription_hospitalization(success, fail) {
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/my_no_prescription_hospitalization.json", dto, success, fail);
}

function grey_get_my_exist_prescription_hospitalization(success, fail) {
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/my_exist_prescription_hospitalization.json", dto, success, fail);
}

function grey_get_group_exist_therapist_hospitalization(groupId, success, fail) {
    var dto={};
    dto.group_id = groupId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/group_exist_therapist_hospitalization.json", dto, success, fail);
}

function grey_get_group_no_therapist_hospitalization(groupId, success, fail) {
    var dto={};
    dto.group_id = groupId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/group_no_therapist_hospitalization.json", dto, success, fail);
}
function grey_get_my_treat_group_syn(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/my_treat_group.json", dto, success, fail);
}

function grey_get_treatment_group_list(hos_id, success, fail) {
    var dto = {};
    dto.hospital_id = hos_id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/treat_group_list.json", dto, success, fail);
}


//这里通过token拿治疗项目，避免医生所属医院或科室发生变化后，前台无法及时知道
function grey_get_treat_item_list_syn(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/treat_item_list.json", dto, success, fail);
}

function grey_get_diagnose_list_syn(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }

    dto.timestamp = new Date().getTime();

    doGetSyn("/mandy/diagnose_list.json", dto, success, fail);
}

function grey_add_diagnose(name, success, fail) {
    var dto = {};
    dto.name = name;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/diagnose.json", dto, success, fail);
}

function grey_delete_diagnose(id, success, fail) {
    var dto = {};
    dto.id = id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doDelete("/mandy/diagnose.json", dto, success, fail);
}


//这里通过token拿床位，避免医生所属医院或科室发生变化后，前台无法及时知道
function grey_get_bed_list_syn(success, fail) {
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGetSyn("/mandy/bed_list.json", dto, success, fail);
}


function grey_post_hospitalization_patient_info(name, sex, birthday, mobile, success, fail) {
    var dto = {};
    dto.name = name;
    dto.mobile = mobile;
    dto.sex = sex;
    dto.birthday = birthday;
    dto.division_id = hosDivId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPost("/mandy/hospitalization_patient_info.json", dto, success, fail);
}

function grey_set_hospitalization_patient_info(hospitalizationId,name, sex, birthday, mobile, success, fail) {
    var dto = {};
    dto.hospitalization_id = hospitalizationId;
    dto.name = name;
    dto.mobile = mobile;
    dto.sex = sex;
    dto.birthday = birthday;
    dto.division_id = hosDivId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/hospitalization_patient_info.json", dto, success, fail);
}

function grey_get_patient_hospitalization(hospitalizationId, success, fail){
    var dto = {};
    dto.hospitalization_id = hospitalizationId;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/patient_hospitalization.json", dto, success, fail);
}

function grey_get_patient_prescription(prcp_id, success, fail) {
    var dto = {};

    dto.prcp_id = prcp_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_prescription.json", dto, success, fail);
}


//查看某个患者当天的治疗记录
function grey_get_patient_treatment_record(patient_id, success, fail) {
    var dto = {};

    dto.patient_id=patient_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_treatment_record.json", dto, success, fail);
}

function grey_get_prescription_item(prcp_id, success, fail) {
    var dto = {};

    dto.prcp_id = prcp_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/prescription_item.json", dto, success, fail);
}

function grey_update_prescription_item_sche(patient_id,perscriptionItemSches, success, fail) {
    var dto = {};

    dto.list = perscriptionItemSches;
    dto.patient_id = patient_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/prescription_item_sche.json", dto, success, fail);
}

function grey_update_treatment_record_status(record_ids,status, success, fail) {
    var dto = {};

    dto.record_ids = record_ids;
    dto.status = status;

    if (!addTokenToDTO(dto)) {
        return;
    }

    debugAlert(dto);

    doPut("/mandy/treatment_record_status.json", dto, success, fail);
}


function grey_get_treat_group_members(success, fail){
    var dto = {};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/treat_group_members.json", dto, success, fail);
}

function grey_set_pcrp_item_therapist(prcp_id,therapist_id,success, fail) {
    var dto = {};
    dto.therapist_id = therapist_id;
    dto.prcp_id = prcp_id;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doPut("/mandy/prcp_item_therapist.json", dto, success, fail);
}

//治疗师治疗完成
function grey_update_prescription_item_status(prcp_id,is_finish, success, fail) {
    var dto = {};

    dto.prcp_id=prcp_id;
    dto.is_finish=is_finish;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doPut("/mandy/prescription_item_status.json", dto, success, fail);
}


function grey_post_record_hospitalization(hosNum, patientId, bedNum, bedId, medicalId, divId, hospitalId,
                                          disInfo, diagnose, treatArea, checkInTime, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    dto.hos_num = hosNum;

    dto.patient = {};
    dto.patient.id = patientId;

    dto.bed = {};
    dto.bed.id = bedId;
    dto.bed.num = bedNum;

    dto.medical = {};
    dto.medical.id = medicalId;

    dto.division = {};
    dto.division.id = divId;

    dto.hospital = {};
    dto.hospital.id = hospitalId;

    dto.disease_info = disInfo;
    dto.diagnose = diagnose;
    dto.treat_area = treatArea;
    dto.check_in_time = checkInTime;

    doPost("/mandy/record_hospitalization.json", dto, success, fail);
}

function grey_set_record_hospitalization(id,hosNum, patientId, bedNum, bedId, medicalId, divId, hospitalId,
                                          disInfo, diagnose, treatArea, checkInTime, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.id = id;

    dto.hos_num = hosNum;

    dto.patient = {};
    dto.patient.id = patientId;

    dto.bed = {};
    dto.bed.id = bedId;
    dto.bed.num = bedNum;

    dto.medical = {};
    dto.medical.id = medicalId;

    dto.division = {};
    dto.division.id = divId;

    dto.hospital = {};
    dto.hospital.id = hospitalId;

    dto.disease_info = disInfo;
    dto.diagnose = diagnose;
    dto.treat_area = treatArea;
    dto.check_in_time = checkInTime;

    doPut("/mandy/record_hospitalization.json", dto, success, fail);
}

function grey_post_add_prescription(oldId,patientId, medicalId, items, hospitalizationId, success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.old_id = oldId;
    //dto.status = status;

    dto.patient = {};
    dto.patient.id = patientId;

    //处方医生就是当前医生，录入病患时是值班医生
    //dto.medical = {};
    //dto.medical.id = medicalId;

    dto.prescription_items = items;

    dto.hospitalization = {};
    dto.hospitalization.id = hospitalizationId;

    doPost("/mandy/prescription.json", dto, success, fail);
}

function grey_get_my_treatment_record(success,fail){
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/my_treatment_record.json", dto, success, fail);
}

function grey_get_group_treatment_record(groupid,success,fail){
    var dto={};
    dto.group_id = groupid;
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/treatment_group_record.json", dto, success, fail);
}

function grey_get_therapist_prescription_hospitalization(success,fail){
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/therapist_prescription_hospitalization.json", dto, success, fail);
}

function grey_post_check_out(hospitalizationId,success,fail){
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    dto.hospitalization_id = hospitalizationId;
    doPost("/mandy/check_out.json", dto, success, fail);
}


function grey_get_prescription_item_patient(patient_id, success, fail) {
    var dto = {};

    dto.patient_id = patient_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/prescription_item_patient.json", dto, success, fail);
}

function grey_get_treatment_group(success, fail){
    var dto={};
    if (!addTokenToDTO(dto)) {
        return;
    }
    doGet("/mandy/treatment_group.json", dto, success, fail);
}

function grey_get_patient_hospitalization_by_prcp_id(prcp_id, success, fail) {
    var dto = {};

    dto.prcp_id = prcp_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_hospitalization_by_prcp_id.json", dto, success, fail);
}

function grey_get_patient_hospitalization_by_patient_id(patient_id, success, fail) {
    var dto = {};

    dto.patient_id = patient_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/patient_hospitalization_by_patient_id.json", dto, success, fail);
}

function grey_get_prescription_by_page(current_page, page_size, type, success, fail) {
    var dto = {};

    dto.current_page = current_page;
    dto.page_size = page_size;
    dto.type = type;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/prescription_by_page.json", dto, success, fail);
}


function grey_get_prescription_list( success, fail) {
    var dto = {};

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/prescription_list.json", dto, success, fail);
}

function grey_get_training_plan(training_plan_id, success, fail) {
    var dto = {};
    dto.training_plan_id = training_plan_id;

    if (!addTokenToDTO(dto)) {
        return;
    }

    doGet("/mandy/get_training_plan_by_id.json", dto, success, fail);
}*/